#ifndef __SKIPITERATOR__

#define __SKIPITERATOR__

#include<iterator>

template<class It>
class skipIterator : public It {
	
	It stop;
	typename std::iterator_traits<It>::value_type skip;
	
	public:
		
	skipIterator(It begin, It end, typename std::iterator_traits<It>::value_type s) : It(begin), stop(end), skip(s) {
		if (*begin == skip)
			operator++();
	}
		
	skipIterator(skipIterator const & it)  : It((It)it), stop(it.stop), skip(it.skip) {}
		
	skipIterator & operator++() {
		do
			It::operator++();
		while ((*this != stop) && It::operator*()==skip);
		return *this;
	}
	
	skipIterator operator++(int) {
		skipIterator res(*this);
		operator++();
		return res;
	}
	
	bool operator==(skipIterator it) {
		return (*this==((It)it) && (skip == it.skip) && (stop == it.stop));
	}
	
	bool operator==(It it) {
		return ((It)*this)==(it);
	}
	
	bool operator!=(skipIterator it) {
		return !operator==(it);
	}
	
	bool operator!=(It it) {
		return !operator==(it);
	}
	
	typename std::iterator_traits<It>::value_type & operator*() {
		return It::operator*();
	}
	
	typename std::iterator_traits<It>::value_type * operator->() {
		return It::operator->();
	}
};

#endif
